import Vue from 'vue'
export default{
    namespaced:true,
    state:()=>({
        addressList:[
            {
                id: '1',
                name: '张三',
                tel: '13100000000',
                province: '浙江省',
                city: '杭州市',
                county: '拱墅区',
                address: '浙江省杭州市拱墅区莫干山路 50 号',
                addressDetail: '浙江省杭州市拱墅区莫干山路 50 号',
                postalCode: '400800',
                isDefault: false,
                areaCode: '340621'
            },

            {
                id: '2',
                name: '李四',
                tel: '13100000000',
                province: '浙江省',
                city: '杭州市',
                county: '拱墅区',
                address: '浙江省杭州市拱墅区莫干山路 50 号',
                addressDetail: '浙江省杭州市拱墅区莫干山路 50 号',
                postalCode: '400800',
                areaCode: '340621',
                isDefault: false,
            },
        ]


    }),

    mutations: {
        addressMut(state, {obj,address}) {
            console.log(obj)
            let num = ""
            let {addressList}=state
            num=addressList.length+1
            Vue.set(obj,'id',num)
            Vue.set(obj,'address',address)
            state.addressList.push(obj)
        },
        addressDelMut(state, obj) { //删除地址
            state.addressList.splice(obj, 1)
        },
        addressReplaceMut(state, { obj, idx, address }) { //编辑地址

            Vue.set(obj, 'address', address)
              state.addressList[idx] = obj

        }
    }
}